package com.quan.TemplateEditor.controller;

import com.quan.TemplateEditor.common.R;
import com.quan.TemplateEditor.dto.AtrributeDefSelectorDto;
import com.quan.TemplateEditor.dto.GisTableParams;
import com.quan.TemplateEditor.entity.AttributeDef;
import com.quan.TemplateEditor.entity.GisTable;
import com.quan.TemplateEditor.interfaces.IdataInterface;
import com.quan.TemplateEditor.params.CodeParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping(value = "/idata")
public class IdataController {
    @Autowired
    IdataInterface idataInterface;

    //图层  获取gistable内容
    @RequestMapping(value = "/getLayer")
    @ResponseBody
    List<GisTable> getLayer() {
        return idataInterface.getLayer();
    }

    //图层 保存图层信息
    @RequestMapping(value = "/saveGisTable")
    @ResponseBody
    void saveGisTable(@RequestBody GisTableParams gisTableParams) {
        idataInterface.saveGisTable(gisTableParams);
    }

    //导入、导出  获取表和表对应的数据量
    @RequestMapping(value = "/getTableInfo")
    @ResponseBody
    List<Map<String,Object>> getTableInfo() {
        return idataInterface.getTableInfo();
    }

    //导入、导出 根据表名称获取表字段信息
    @RequestMapping(value = "/getTableInfoByName")
    @ResponseBody
    List<Map<String,Object>> getTableInfoByName(String tableName) {
        return idataInterface.getTableInfoByName(tableName);
    }

    //属性 获取属性内容
    @RequestMapping(value = "/getAttribute")
    @ResponseBody
    List<AttributeDef> getAttributeByTableName(String tableName) {
        return idataInterface.getAttributeByTableName(tableName);
    }

    //属性 获取属性功能中下拉列表
    @RequestMapping(value = "/getAttributeSelector")
    @ResponseBody
    List<AtrributeDefSelectorDto> getAttributeSelector() {
        return idataInterface.getAttributeSelector();
    }

    //编码 树列表
    //属性 获取属性功能中下拉列表
    @RequestMapping(value = "/getQrCode")
    @ResponseBody
    R getQrCode(@RequestBody CodeParams code) {
        return idataInterface.getQrCode(code);
    }

    //编码 树列表
    //属性 获取属性功能中下拉列表
    @RequestMapping(value = "/validate")
    @ResponseBody
    R validate(@RequestBody CodeParams code) {
        return idataInterface.validate(code);
    }

    //数据转换为Point
    @RequestMapping(value = "/getMinMaxXY")
    @ResponseBody
    Double[][][] getMinMaxXY(@RequestBody CodeParams code) {
        return idataInterface.GetMinMaxXY(code);
    }
}
